// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using BenchmarkDotNet.Attributes;

using Colourful;

using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
using Illuminants = Colourful.Illuminants;

namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces;

public class ColorspaceCieXyzToCieLabConvert
{
    private static readonly CieXyz CieXyz = new CieXyz(0.95047F, 1, 1.08883F);

    private static readonly XYZColor XYZColor = new XYZColor(0.95047, 1, 1.08883);

    private static readonly ColorSpaceConverter ColorSpaceConverter = new ColorSpaceConverter();

    private static readonly IColorConverter<XYZColor, LabColor> ColourfulConverter = new ConverterBuilder().FromXYZ(Illuminants.D50).ToLab(Illuminants.D50).Build();

    [Benchmark(Baseline = true, Description = "Colourful Convert")]
    public double ColourfulConvert()
    {
        return ColourfulConverter.Convert(XYZColor).L;
    }

    [Benchmark(Description = "ImageSharp Convert")]
    public float ColorSpaceConvert()
    {
        return ColorSpaceConverter.ToCieLab(CieXyz).L;
    }
}
